﻿                                    
function chkfilesize(fileName){
		var filetype=fileName.substring(fileName.lastIndexOf('.'),fileName.length);
		filetype=filetype.toLowerCase();
		if(filetype==".bmp"||filetype==".tif"){//不支持上传.bmp，.tif文件！
			alert("不支持上传.bmp，.tif文件！");
			document.getElementById("ufspan").innerHTML = "<input type=\"file\" name=\"caseFileFORMFILE\" value=\"\" onchange=\"chkfilesize(this.value);\"/>";
			return false;
		}else{	
			var maxsize = 10;    //定义允许文件的大小，单位KB，请根据需要自行修改！
		    var fso = new ActiveXObject('Scripting.FileSystemObject');
		    var file = fso.GetFile(fileName);
		    var filelen=file.Size;
		    hiddenDSCRIPT();
		    document.all.caseFile.value="";
		    if(Math.round(filelen/(1024*1024),2)>maxsize)
		    {
		    	if (confirm("抱歉！您选择的文件为 "+Math.round(filelen/(1024*1024),2)+" M，超过了程序"+maxsize+" M 的限制！\n普通的上传方式不能上传这么大的文件，\n你只能通过手动ftp方式传送到服务器上面，\n是否需要手工传送文件？")){
		    		ShowDSCRIPT();
		    		document.all.caseFile.value=fileName;
		    		document.getElementById("ufspan").innerHTML = "<input type=\"file\" name=\"caseFileFORMFILE\" value=\"\" onchange=\"chkfilesize(this.value);\"/>";
		    	}else{
		    		document.getElementById("ufspan").innerHTML = "<input type=\"file\" name=\"caseFileFORMFILE\" value=\"\" onchange=\"chkfilesize(this.value);\"/>";
		    	}
		    }			
		}
}
var currentTbdy=null;


function dataObject(aChildId,aText) {
	this.childId = aChildId;
	this.text = aText;
}

function arrayObject(aParentId,aArray) {
	this.parentId = aParentId;
	this.array = aArray;
}
var dropArray = new Array(3);
var childArray0= new Array(7);
childArray0[0] = new dataObject("101","病毒入侵");
childArray0[1] = new dataObject("102","安全入侵");
childArray0[2] = new dataObject("103","赌博");
childArray0[3] = new dataObject("104","诈骗");
childArray0[4] = new dataObject("105","淫秽色情");
childArray0[5] = new dataObject("106","网上盗窃");
childArray0[6] = new dataObject("107","非法网络公关");
dropArray[0] = new arrayObject("100",childArray0);
var childArray1= new Array(13);
childArray1[0] = new dataObject("201","违反宪法");
childArray1[1] = new dataObject("202","攻危害国家安全");
childArray1[2] = new dataObject("203","损害国家利益");
childArray1[3] = new dataObject("204","破坏民族团结");
childArray1[4] = new dataObject("205","宣扬邪教和封建迷信");
childArray1[5] = new dataObject("206","扰乱社会秩序");
childArray1[6] = new dataObject("207","赌博");
childArray1[7] = new dataObject("208","诈骗");
childArray1[8] = new dataObject("209","淫秽色情");
childArray1[9] = new dataObject("210","侵害他人合法权益");
childArray1[10] = new dataObject("211","非法集会");
childArray1[11] = new dataObject("212","非法民间组织活动");
childArray1[12] = new dataObject("213","其他内容");
dropArray[1] = new arrayObject("200",childArray1);
var childArray2= new Array(0);
dropArray[2] = new arrayObject("300",childArray2);

function Init(){
	var alertwebtype=document.all.alertBigType;
	var parentvalue=alertwebtype.options[alertwebtype.selectedIndex].value;
	if(parentvalue!=""){
		if(currentTbdy!=null)
		currentTbdy.style.display='none';
		if(currentTbdy!=null)
		currentTbdy.style.display='';
	}

var ynregistuser = "null";

}

function cascadeDrop(alertwebtype,destSelect){
	var parentValue = alertwebtype.options[alertwebtype.selectedIndex].value;

	if(parentValue != "") {//如果没有选择主下拉框中的元素.
		ShowSelectTableTR(parentValue);
		for(var i = 0; i < dropArray.length; i++) {
			if(parentValue == dropArray[i].parentId) {
				destSelect.options.length = 0;//清空联动下拉框.
				var destArray = dropArray[i].array;
				for(var j = 0; j < destArray.length; j++) {
					var destValue = destArray[j].childId;
					var destText = destArray[j].text;
					destSelect.options[j] = new Option(destText, destValue);
				}
			}
		}
	} else {
		destSelect.options.length = 0;//清空联动下拉框.
		destSelect.options[0] = new Option(" - None selected - ","");
	}
	function ShowSelectTableTR(parentValue){
		if(parentValue!=""){
			if(currentTbdy!=null)
				currentTbdy.style.display='none';
			if(currentTbdy!=null)
				currentTbdy.style.display='';
		}
	}
}
function validateManuAlertForm()
{       
     
	
	if((document.manuAlertForm.caseDesc.value==null)||(document.manuAlertForm.caseDesc.value==""))
	{
		alert("请输入事件描述！");
		document.manuAlertForm.caseDesc.focus();
		return false;
	}
	if(document.manuAlertForm.caseDesc.value.length>1024){
		alert("事件描述最大长度暂定为1024个字符!");
		document.manuAlertForm.caseDesc.focus();
		return false; 
	}
	
	if((document.manuAlertForm.url.value==null)||(document.manuAlertForm.url.value==""))
	{
		alert("请输入网站网址！");
		document.manuAlertForm.url.focus();
		return false;
	}
	
	if((document.manuAlertForm.alarmcheckcode.value==null)||(document.manuAlertForm.alarmcheckcode.value)=="")
	{
		alert("请输入举报校验码！");
		document.manuAlertForm.alarmcheckcode.focus();
		return false;
	}
	document.manuAlertForm.submit();
}

function resetManuAlertForm()
{
	document.manuAlertForm.reset();
}

/**
*校验字符串是否符合自定义正则表达式
*str 要校验的字串 pat 自定义的正则表达式
*返回值：
*如果为空，定义校验通过， 返回true
*如果字串符合，校验通过， 返回false
*如果字串不符合， 返回true 参考提示信息：必须满足***模式
*/
function checkMask(str,pat)
{
	//如果值为空，通过校验
	if (str == "")
	return true;
	var pattern = new RegExp(pat,"gi")
	if (pattern.test(str))
	return false;
	else
	return true;
}//


function checkType() {


    var vpollname = document.getElementById("pollname").value;
    if (vpollname == "") {
        alert("请填写污染源名称!");
        return false;
    }
    

    var vlat = document.getElementById("lat").value;

    var vlon = document.getElementById("lon").value;

    if (vlat == "" || vlon == "") {
        alert("请在地图上选择污染源地址!");
        return false;
    }

    var vcaseDesc = document.getElementById("caseDesc").value;

    if (vcaseDesc == "") {
        alert("请选择污染源详细描述!");
        return false;
    }

    var vuserName = document.getElementById("userName").value;
    if (vcaseDesc == "") {
        alert("请填写联系人姓名!");
        return false;
    }

    var vuserPhone = document.getElementById("userPhone").value;
    if (vcaseDesc == "") {
        alert("请填写联系电话!");
        return false;
    }
   
    //得到上传文件的值
    var fileName = document.getElementById("FileUpLoad1").value;
    if (fileName == "") {
        alert("请选择污染源的照片!");
        return false;
    }

    //返回String对象中子字符串最后出现的位置.  
    var seat = fileName.lastIndexOf(".");

    //返回位于String对象中指定位置的子字符串并转换为小写.  
    var extension = fileName.substring(seat).toLowerCase();

    var allowed = [".jpg", ".gif", ".png", ".jpeg"];
    for (var i = 0; i < allowed.length; i++) {
        if (!(allowed[i] != extension)) {
            return true;
        }
    }
    alert("照片不支持" + extension + "格式");
    return false;
}  
